package com.tuo51.evaluate.repositories.article;

import com.tuo51.evaluate.domain.news.ArticleListItem;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ArticleListItemRepository extends JpaRepository<ArticleListItem, String>, JpaSpecificationExecutor<ArticleListItem> {

    Page findAllByChannelAndDeletedIsFalseOrderByOrderWeightDesc(String channel, Pageable pageable);

    Page findAllByChannelAndDeletedIsFalseAndVipIsFalseOrderByOrderWeightDesc(String channel, Pageable pageable);

    ArticleListItem findFirstByTitleAndChannelAndDeletedIsFalse(String title, String channel);
    ArticleListItem findFirstByTitleAndChannelIsNullAndDeletedIsFalse(String title);

    List<ArticleListItem> findAllByIdIn(List<String> ids);

}
